#define  _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>

int main()
{
    long long n = 0, arr[10000] = { 0 }, i = 0, max = 0, min = 0;
    scanf("%lld", &n);
    for (i = 0, max = 0, min = 0; i < n; i++)
    {
        scanf("%lld", &arr[i]);
        if (arr[i] > arr[max])
            max = i;
        else if (arr[i] < arr[min])
            min = i;
    }
    printf("%d %d\n", arr[max], arr[min]);
    return 0;
}